package edu.famework.demo6;

import java.awt.font.FontRenderContext;
import java.util.*;

public class Appear3 {
//    3.有十万个数据，统计每个数据出现了多少次
public static void main(String[] args) {
    List<Integer> list = new ArrayList<>();
    Random r = new Random();
    for (int i = 0; i < 100000; i++) {
        int x = r.nextInt(100000);
        list.add(x);
    }
    Map<Integer,Integer> map = new HashMap<>();
    for (Integer key:list){
        if(map.get(key) == null){
            map.put(key,1);
        }else{
            int count = map.get(key);
            map.put(key,count+1);
        }
    }
    for (Map.Entry<Integer,Integer> entry:map.entrySet()){
        System.out.println(entry.getKey()+"出现了"+entry.getValue());
    }
}
}

